package com.dodoke.controller;

import java.util.List;

import com.dodoke.domain.WxDetailQr;
import com.dodoke.domain.WxQr;
import com.dodoke.service.IWxDetailQrService;
import com.dodoke.validateGroup.OnAdd;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.dodoke.common.annotation.Log;
import com.dodoke.common.core.controller.BaseController;
import com.dodoke.common.core.domain.AjaxResult;
import com.dodoke.common.enums.BusinessType;
import com.dodoke.common.utils.poi.ExcelUtil;
import com.dodoke.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 【二维码】Controller
 * 
 * @author dodoke
 * @date 2020-08-25
 */
@RestController
@RequestMapping("/detailQr")
@Api("二维码")
@Validated
public class WxDetailQrController extends BaseController
{
    @Autowired
    private IWxDetailQrService wxDetailQrService;

    /**
     * 查询【二维码】列表
     */
    @ApiOperation("查询二维码详情列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "wxDetailQr",value = "二维码对应的实体类",dataType = "WxDetailQr",required = true,paramType = "form"),
            @ApiImplicitParam(name = "pageNum",value = "当前页码",dataType = "int"),
            @ApiImplicitParam(name = "pageSize",value = "每页展示的记录条数",dataType = "int"),
            @ApiImplicitParam(name = "orderByColumn",value = "由哪个字段排序",dataType = "String"),
            @ApiImplicitParam(name = "isAsc",value = "升序降序",dataType = "String")
    })
    @GetMapping("/list")
    public TableDataInfo list(WxDetailQr wxDetailQr)
    {
        startPage();
        List<WxDetailQr> list = wxDetailQrService.selectWxDetailQrList(wxDetailQr);
        return getDataTable(list);
    }

    /**
     * 新增【二维码】
     * @param code 同一编码值的二维码对应同一数据源
     */
    @ApiOperation("生成新的二维码")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code",value = "编码值",paramType = "path")
    })
    @PostMapping("/insertWxDetailQr/{code}")
    public AjaxResult insertWxDetailQr(@PathVariable String code)
    {
        return toAjax(wxDetailQrService.insertWxDetailQr(code));
    }


    /***
     * 根据id查询二维码
     * @param id
     * @return
     */
    @ApiOperation("根据id查询二维码")
    @ApiImplicitParam(name = "id",value = "二维码对应的实体类",paramType = "head")
    @GetMapping("/selectWxDetailQrById/{id}")
    public AjaxResult selectWxDetailQrById(@PathVariable Long id) {
        WxDetailQr detailQr = wxDetailQrService.selectWxDetailQrById(id);
        return AjaxResult.success(detailQr);
    }


    /**
     * 删除二维码
     * @param id
     * @return
     */
    @ApiOperation("删除二维码")
    @ApiImplicitParam(name = "id",value = "二维码id",dataType = "int",paramType = "head")
    @RequestMapping(value = "/deleteWxDetailQrById/{id}",method = RequestMethod.DELETE)
    public AjaxResult deleteWxDetailQrById(@PathVariable Long id) {
        int affectNum = wxDetailQrService.deleteWxDetailQrById(id);
        return toAjax(affectNum);
    }

}
